﻿using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(PetAsset))]
public class PetAssetEditor : Editor {

	private PetAsset asset;
	
	void Awake()
	{
		asset = (PetAsset)target;
	}
	
	public override void OnInspectorGUI()
	{
		EditorGUILayout.LabelField("SN", asset.SN.ToString());
		asset.Name = EditorGUILayout.TextField("名字", asset.Name);
		asset.Sex = (PetAsset.Sexes)EditorGUILayout.EnumPopup("性别", asset.Sex);
		asset.Avatar = (Texture2D)EditorGUILayout.ObjectField("形象", asset.Avatar, typeof(Texture2D), false);
		asset.Cry = (AudioClip)EditorGUILayout.ObjectField("叫声", asset.Cry, typeof(AudioClip), false);
		asset.PetData = (PetDataAsset)EditorGUILayout.ObjectField("魔法兽数值", asset.PetData, typeof(PetDataAsset), false);
		asset.InitSkill = (SkillAsset)EditorGUILayout.ObjectField("初始技能", asset.InitSkill, typeof(SkillAsset), false);
		if (GUI.changed)
		{
			if (asset.SN < 10000)
			{
				Debug.LogWarning(string.Format("{0}.SN: cannot less then 10000.", asset.ToString()));
			}
			EditorUtility.SetDirty(asset);
		}
	}
}
